<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function Dog(name, age) {
        this.name = name;
        this.age = age;
    }

    Dog.prototype.run = function () {
        console.log(this.name, 'Running......');
    }
    Dog.prototype.eat = function () {
        console.log(this.name, 'Eating......');
    }
    let dog = new Dog('coco', 3);
    console.log('----------------');
    dog.run();
    dog.eat();
    console.log('----------------');
    // 实例对象的原型对象 -- 对象.__proto__方法()    相当于构造函数的原型对象 - 函数.prototype.方法
    console.log(dog.__proto__ == Dog.prototype); //true
    dog.__proto__.run(); //__proto__不是一个标准的属性，里面的this是undefined
    Dog.prototype.run();

    //如果私有属性与公共属性冲突
    Dog.prototype.name = 'XXX';
    console.log(dog.name); //coco
    console.log(dog.__proto__.name); //XXX
</script>

</html>